/*
 * Create in 2013-4-20 上午11:27:59.
 */
package kit4j.app.notepad.ui.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import kit4j.app.notepad.command.NotepadCommandExecutor;
import kit4j.app.notepad.service.ExceptionCatchService;
import kit4j.common.command.FullCommand;

/**
 * 
 * @author MiniKnife
 *
 */
public class ExecuteCommandActionListener implements ActionListener {
	
	private final FullCommand command;
	
	private final NotepadCommandExecutor commandExecutor;
	
	public ExecuteCommandActionListener(FullCommand command, NotepadCommandExecutor commandExecutor) {
		this.command = command;
		this.commandExecutor = commandExecutor;
	}

	/**
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		try {
			commandExecutor.execute(command);
		} catch (Exception e1) {
			ExceptionCatchService.getInstance().catchException(e1);
		}
	}

}
